import { Inject,Post } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { MallCategoryEntity } from '../../entity/category';
import { MallCategoryService } from '../../service/category';


/**
 * 商品分类
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: MallCategoryEntity,
  service: MallCategoryService,
  pageQueryOp: {
    keyWordLikeFields: ['name'],
    fieldEq: ['parentId'],
    addOrderBy: {
      order: 'ASC',
    },
  },
})
export class AdminMallCategoryController extends BaseController {
  @Inject()
  mallCategoryService: MallCategoryService;

  @Post('/getCategoryGoodsCount', { summary: '获得分类商品数量' })
  async getCategoryGoodsCount() {
    return this.ok(await this.mallCategoryService.getCategoryGoodsCount());
  }
}
